<?php

namespace common\modules\ad\models\backend;

use common\widgets\ActiveForm;
use common\widgets\Form;
use Yii;
use yii\helpers\ArrayHelper;
use yii\web\ServerErrorHttpException;

/**
 * This is the form model class for model "Item".
 */
class ItemForm extends \common\modules\ad\models\backend\Item
{

    /**
     * @inheritdoc
     */
    public $isNewRecord;

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return parent::rules();
    }

    const SCENARIO_CREATE = 'admin-create';
    const SCENARIO_UPDATE = 'admin-update';

    /**
     * @inheritdoc
     */
    public function scenarios()
    {
        return [
            'admin-create' => ['id', 'position_id', 'media_type', 'name', 'link', 'code', 'start_time', 'end_time', 'link_man', 'link_email', 'link_phone', 'click_count', 'status', 'created_at', 'updated_at', 'created_by', 'updated_by'],
            'admin-update' => ['id', 'position_id', 'media_type', 'name', 'link', 'code', 'start_time', 'end_time', 'link_man', 'link_email', 'link_phone', 'click_count', 'status', 'created_at', 'updated_at', 'created_by', 'updated_by'],
        ];
    }

    /**
     * 返回当前表单的名称
     *
     * @return string
     */
    public function classLabelName()
    {
        return Yii::t('backend/ad', 'Item');
    }

    /**
     * 列表定义
     *
     * @param ActiveForm|Form $form
     * @param $model ItemForm
     * @param mixed $extra
     * @return array
     * @throws \yii\web\ServerErrorHttpException
     */
    public function formRows(&$form, $model, $extra)
    {
        return [
            [
                'box' => ['title' => "基础信息"],
                'columns' => 2,
                'attributes' => [
                                            
                    'id' => [
                        'type' => Form::INPUT_TEXT,
                        'options' => ['disabled' => true],
                    ],
                                                                        
                    'position_id' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'media_type' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'name' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'link' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'code' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'start_time' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'end_time' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'link_man' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'link_email' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'link_phone' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'click_count' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'status' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'created_at' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'updated_at' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'created_by' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                                        
                    'updated_by' => [
                        'type' => Form::INPUT_TEXT
                    ],
                                                
                ],
            ],
        ];
    }

}
